define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'rui/shenfenshenhe/index' + location.search,
                    // add_url: 'rui/shenfenshenhe/add',
                    // edit_url: 'rui/shenfenshenhe/edit',
                    del_url: 'rui/shenfenshenhe/del',
                    multi_url: 'rui/shenfenshenhe/multi',
                    // import_url: 'rui/shenfenshenhe/import',
                    table: 'rui_shenfenshenhe',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'nickname', title: '申请人'},
                        {
                            field: 'type2',
                            title: '申请岗位',
                            formatter: Table.api.formatter.type
                        },
                        {
                            field: 'status',
                            title: '申请状态',
                            searchList: {"0": '未审核', "1": '审核通过', "2": '审核拒绝'},
                            formatter: Table.api.formatter.status
                        },
                        {
                            field: 'memo',
                            title: '姓名',
                        },
                        {field: 'image', title: '证件', events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
                        {
                            field: 'province_name',
                            title: '所属省份',
                        },
                        {
                            field: 'company_name',
                            title: '所属公司',
                        },
                        {
                            field: 'zhengjian_daoqi',
                            title: '证件到期时间',
                        },
                        {
                            field: 'create_at',
                            title: __('Create_at'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false
                        },
                        {
                            field: 'operate',
                            buttons: [
                                {
                                    name: 'ajax',
                                    text: '审核通过',
                                    title: '审核通过',
                                    refresh:true,
                                    classname: 'btn btn-xs btn-success btn-magic btn-ajax',
                                    icon: 'fa fa-magic',
                                    url:"https://shanghaihuxi.cn/api/csmwj/xcmy_clogin_api/shenfenshenhe2?status=1&id={id}",
                                    visible: function (row) {
                                        //返回true时按钮显示,返回false隐藏
                                        if(row.status > 0){
                                            return false;
                                        }else{
                                            return true;
                                        }
                                    },
                                    confirm: '确定操作吗',

                                },
                                {
                                    name: 'ajax',
                                    text: '审核拒绝',
                                    title: '审核拒绝',
                                    refresh:true,
                                    classname: 'btn btn-xs btn-warning btn-addtabs btn-ajax',
                                    icon: 'fa fa-magic',
                                    url:"https://shanghaihuxi.cn/api/csmwj/xcmy_clogin_api/shenfenshenhe2?status=2&id={id}",
                                    confirm: '确定操作吗',
                                    visible: function (row) {
                                        //返回true时按钮显示,返回false隐藏
                                        if(row.status > 0){
                                            return false;
                                        }else{
                                            return true;
                                        }
                                    }
                                }
                            ],
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
